﻿using System;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.ComponentModel;
using FingerReader;
using RemObjects.SDK;
using RemObjects.SDK.Types;

namespace FingerReaderClient
{
    public partial class MainForm : System.Windows.Forms.Form, IFingerReaderEvents
    {
        private FingerReader.IFingerReaderService _fingerReaderService;
        public MainForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        public void StatusReport(FingerReaderStatus Status)
        {
            Action<string> ac = s => this.label1.Text = s;
            this.BeginInvoke(ac, Status.ToString());
        }

        public void QualityReport(int Quality)
        {
            throw new NotImplementedException();
        }

        public void Complete(Binary Sample)
        {
            throw new NotImplementedException();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                _fingerReaderService = CoFingerReaderService.Create(message, clientChannel);

                eventReceiver.RegisterEventHandler(this, typeof(IFingerReaderEvents));
                _fingerReaderService.Connect();


            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }

        private void UpdateStatus(string status)
        {
            this.label1.Text = status;
        }

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
           // eventReceiver.UnregisterEventHandler(this);
        }
    }
}
